package com.service.Impl;

import com.dao.AccountDao;
import com.dao.FamilyDao;
import com.dao.OperatorDao;
import com.dao.PoorDao;
import com.pojo.Account;
import com.pojo.Family;
import com.pojo.Operator;
import com.service.OperatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperatorServiceImpl implements OperatorService {
    @Autowired
    OperatorDao operatorDao;

    @Autowired
    AccountDao accountDao;

    @Autowired
    FamilyDao familyDao;

    @Autowired
    PoorDao poorDao;
    @Override
    public Operator login(Operator operator) {
        return operatorDao.login(operator);
    }

    @Override
    public List<Account> getAllAccount(Integer areaId) {
        return  accountDao.selectAllByAreaIdAccounts(areaId);
    }

    @Override
    public String selectPoorKind(Integer id) {
         return poorDao.selectPoorKind(id);
    }

    @Override
    public Integer selectSum(Integer accountId) {
        return familyDao.selectSum(accountId);
    }

    @Override
    public Integer selectPoorId(String poorKind) {
        return poorDao.selectPoorId(poorKind);
    }

    @Override
    public boolean addAccount(Account account) {
        return accountDao.insert(account)>0;
    }

    @Override
    public boolean deleteAccount(Integer id) {
        return accountDao.deleteById(id)>0;
    }

    @Override
    public boolean updateAccount(Account account) {
        return accountDao.updateById(account)>0;
    }

    @Override
    public List<Family> selectByAccountId(Integer id) {
        return familyDao.searchAccountIdFamilies(id);
    }

    @Override
    public boolean addFamily(Family family) {
        return familyDao.insert(family)>0;
    }

    @Override
    public boolean updateFamily(Family family) {
        return familyDao.updateById(family)>0;
    }

    @Override
    public boolean deleteFamily(Integer id) {
        return familyDao.deleteById(id)>0;
    }


}
